<%@ page import="java.util.Map" %>
<%@ page import="com.qf.pojo.ShopCart" %>
<%@ page import="com.qf.pojo.ShopItem" %>
<%@ page import="java.util.Iterator" %><%--
  Created by IntelliJ IDEA.
  User: 宋晓博
  Date: 2022/1/14
  Time: 0:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
<%@include file="header.jsp" %>
<html>
<head>
    <meta charset="utf-8"/>
    <title>购物车详情</title>
    <link type="text/css" rel="stylesheet" href="static/bootstrap-3.4.1-dist/css/bootstrap.css"/>
</head>
<body>
<script type="text/javascript" src="static/bootstrap-3.4.1-dist/js/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="static/bootstrap-3.4.1-dist/js/bootstrap.js"></script>
<script type="text/javascript" src="static/js/cart.js"></script>
<div class="container">
    <form action="/cart" method="get" id="from">
        <input type="hidden" name="method" value="generate">
        <C:if test="${empty requestScope.sys_cart}">
            <h3>购物车空空如也！</h3>
        </C:if>
        <C:if test="${!empty requestScope.sys_cart}">
            <div class="col-md-10 col-md-offset-1">
                <h3>订单预览：</h3>
                <table class="table  table-striped table-hover" style="text-align:center">
                    <tr>
                        <th>多选</th>
                        <th>序号</th>
                        <th>商品名称</th>
                        <th>价格</th>
                        <th>数量</th>
                        <th>修改</th>
                        <th>小计</th>
                        <th>删除商品</th>
                    </tr>

                    <c:forEach items="${requestScope.sys_cart}" var="item" varStatus="i">
                        <tr class="hang">
                            <th><input type="checkbox" class="selectgoods" name="ids" value="${item.goods.id}"></th>
                            <th>${i.count}</th>
                            <th>${item.goods.name}</th>
                            <th>${item.goods.price}</th>
                            <th class="goodsnum">${item.num}</th>

                            <th width="100px">
                                <div class="input-group">
                                <span class="input-group-btn">
                                    <button class="btn btn-info" type="button"
                                            onclick="modify(${item.goods.id},-2,${i.index},${item.goods.price})">-</button>
                                </span>
                                    <input type="text" class="form-control inputnum" value="${item.num}"
                                           onchange="modify(${item.goods.id},0,${i.index},${item.goods.price})"
                                           onfocus="getValue(${i.index})"
                                           style="width: 40px">
                                    <span class="input-group-btn">
                                    <button class="btn btn-info" type="button"
                                            onclick="modify(${item.goods.id},-1,${i.index},${item.goods.price})">+</button>
                                </span>
                                </div>
                            </th>

                            <th class="totalmoney">${item.goods.price*item.num}</th>

                            <th>
                            <span class="input-group-btn">
                                    <button class="btn btn-info" type="button"
                                            onclick="deblete(${item.goods.id},${i.index})">
                                    删除<span class="glyphicon glyphicon-remove-sign"></span>
                                    </button>
                            </span>
                            </th>
                        </tr>
                    </c:forEach>
                </table>
            </div>

            <div class="row">
                <div class="pull-right" style="margin-right: 40px;">
                    <div>
                        <a id="removeAllProduct" href="javascript:clearCart(0)" class="btn btn-default btn-md">清空购物车</a>
                            <%--a href="cart?meyhod=generate" class="btn  btn-danger btn-md addAddres">添加收货地址</a>--%>
                        <input type="submit" class="btn btn-danger btn-md addAddres" value="添加收货地址">
                    </div>
                    <br>
                    <div style="margin-bottom: 20px;">
                        商品金额总计：<span class="text-danger">
                    ￥<span id="allmoney">0</span>
                </span>
                    </div>
                </div>
            </div>
        </C:if>
    </form>

</div>

</body>
</html>
